<!DOCTYPE html>
<html>
<head>
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords"
          content="Internship Sign In & Sign Up Form Responsive Widget,Login form widgets, Sign up Web forms , Login signup Responsive web form,Flat Pricing table,Flat Drop downs,Registration Forms,News letter Forms,Elements"/>
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);
    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <!-- Custom Theme files -->
    <link href="../../resources/index/css/font-awesome.min.css" rel="stylesheet" type="text/css" media="all">
    <link href="../../resources/index/css/snow.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="../../resources/index/css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <script style="text/javascript" src="../../resources/lib/jQuery/jquery-3.1.1.js"></script>
    <script style="text/javascript" src="../../resources/index/js/login-user-id.js"></script>
</head>
<body>
<div class="snow-container">
    <div class="snow foreground"></div>
    <div class="snow foreground layered"></div>
    <div class="snow middleground"></div>
    <div class="snow middleground layered"></div>
    <div class="snow background"></div>
    <div class="snow background layered"></div>
</div>

<div class="top-buttons-agileinfo">
    <a href="login.html" class="active">登录</a><a href="signup.html">注册</a>
</div>
<h1>欢迎登陆
</h1>

<div class="main-agileits">
    <!--form-stars-here-->
    <div class="form-w3-agile">
        <h2 class="sub-agileits-w3layouts">登录</h2>

        <form action="#" id='submitform' name="frm-reg">
            <input id="email" type="email" name="Eamil" placeholder="用户" required="required"/>
            <input id="password" type="password" name="Password" placeholder="密码" required="required"/>
            <a href="" class="forgot-w3layouts">忘记密码 ?</a>

            <div class="submit-w3l">
                <input type="submit" value="登录">
            </div>
            <p class="p-bottom-w3ls"><a href="signup.html">点击注册</a>如果你没有一个帐户。</p>
        </form>
    </div>
</div>


<script type="text/javascript">
    $(document).ready(function () {

        $("#submitform").on("submit", function (ev) {
            var email = $("#email").val();
            var password = $("#password").val();
            console.log(email);
            $.ajax({
                type: 'POST',
                url: 'http://www.xiaowenxiong.cn/test/users/login',
                data: {
                    email: email,
                    password: password
                },
                dataType: 'json',
                success: function (result) {
                    if (result.error == 104) {
                        alert('用户名或密码错误！');
                    } else if (result.error == 0) {

                        window.location.href = "../travel-note/travel-note.html";
                        //存储
                        window.sessionStorage.setItem(loginUserId, result.data.userId);
                        // 读取
//                        var tempData = window.sessionStorage.getItem(loginUserId);
//                        alert('loginUserId:'+tempData)
                    }

                },
                error: function (xhr, type) {

                    alert('上传超时啦，再试试');
                }
            });


            //阻止submit表单提交
            ev.preventDefault();
            //或者return false
            //return false;
        });

    })
</script>
</body>
</html>